<?php

/**
 * ajax返回数据
 * @param int $status       状态码
 * @param string $msg       描述
 * @param array $data       数据
 * @return string
 */
if(!method_exists('ajax_return')){
    function ajax_return($status=1, $msg='', $data=[]){
        $res['status'] = $status;
        $res['msg'] = $msg;
        $res['data'] = $data;
        exit(json_encode($res));
    }
}

 /** 时间日期转时间戳格式，精确到毫秒，
  *     
  */
 function get_data_format($time)
 {
    list($usec, $sec) = explode(".", $time);
    $date = strtotime($usec);
    $return_data = str_pad($date.$sec,13,"0",STR_PAD_RIGHT); //不足13位。右边补0
    return $return_data;
 }

 //去掉数字逗号
function str_d($str){
    $arr = explode(',', $str);
    $newstr = '';
    foreach ($arr as $k => $v) {
        $newstr .= $v;
    }
    
    return $newstr;
}

//获取当前活动日期
//$type =1 日期 其他时间戳
function get_activity_date($type =1){
    $r = M('seeting')->where(['name'=>'ACTIVITY_START_DATE'])->find();
    if($type == 1){
        return $r['value'];
    }else{
        return strtotime($r['value']);
    }
}